package com.gitee.wsl.compose.animation.transition

import androidx.compose.animation.core.FiniteAnimationSpec
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.spring
import androidx.compose.animation.scaleIn
import androidx.compose.animation.scaleOut
import androidx.compose.runtime.Stable
import androidx.compose.ui.graphics.TransformOrigin

//缩放进入动画。该动画会使对象逐渐从较小的大小缩放到正常大小。
@Stable
fun Transition.In.scale(
    animationSpec: FiniteAnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow),
    initialScale: Float = 0f,
    transformOrigin: TransformOrigin = TransformOrigin.Center,
) = scaleIn(animationSpec, initialScale, transformOrigin)

//缩放离开动画。该动画会使对象逐渐从正常大小缩放到较小的大小。
@Stable
fun Transition.Out.scale(
    animationSpec: FiniteAnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow),
    initialScale: Float = 0f,
    transformOrigin: TransformOrigin = TransformOrigin.Center,
) = scaleOut(animationSpec, initialScale, transformOrigin)